import React, { Component, PureComponent } from 'react';

export class DemoPureComponet extends Component {
  constructor() {
    super();
    this.state = {
      name: 'mike'
    };
  }

  updateName() {
    setInterval(() => {
      this.setState({ name: 'mike' });
    }, 1000);
  }

  componentDidMount() {
    this.updateName();
  }

  render() {
    return (
      <>
        <Regular name={this.state.name} />
        <PureCompoentDemo name={this.state.name} />
      </>
    );
  }
}

class Regular extends Component {
  render() {
    console.log('Regular component');
    return <div>{this.props.name} --- Regular</div>;
  }
}

class PureCompoentDemo extends PureComponent {
  render() {
    console.log('Pure component');
    return <div>{this.props.name} --- PureComponent</div>;
  }
}
